package com.motong.gongdan.vo.system.device.vo;


import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

@ApiModel("设备列表返回值")
@Data
public class DeviceListVo implements Serializable {

    @ApiModelProperty(value = "id")
    private Long id;

    @ApiModelProperty(value = "分组id")
    private Long groupId;

    @ApiModelProperty(value = "分组名称")
    private String groupName;

    @ApiModelProperty(value = "设备名称")
    private String deviceName;

    @ApiModelProperty(value = "绑定人员(user表id)")
    private Integer bindUser;

    @ApiModelProperty(value = "绑定人员名称")
    private String bindUserName;

    @ApiModelProperty(value = "绑定状态")
    private String bindStatus = "未绑定";

    @ApiModelProperty(value = "设备管理员")
    private Integer deviceAdmin;

    @ApiModelProperty(value = "设备管理员名称")
    private String deviceAdminName;

    @ApiModelProperty(value = "设备图片")
    private String devicePic;

    @ApiModelProperty(value = "设备编号")
    private String deviceSn;

    @ApiModelProperty(value = "设备序列号")
    private String realDeviceSn;

    @ApiModelProperty(value = "状态(0 关机, 1 运行, 2 等待, 3 故障, 4 离线)")
    private Integer status = 4;

    @ApiModelProperty(value = "状态名称")
    private String statusName = "离线";

    @ApiModelProperty(value = "启用时间")
    private Date enableTime;

    @ApiModelProperty(value = "启用时长")
    private String enableDurationCn;

    @ApiModelProperty(value = "备注")
    private String remark;


    public void setBindUser(Integer bindUser) {
        if (Objects.nonNull(bindUser)) {
            bindStatus = "已绑定";
        }
        this.bindUser = bindUser;
    }

    public void setStatus(Integer status) {
        switch (status) {
            case 0:
                statusName = "关机";
                break;
            case 1:
                statusName = "运行";
                break;
            case 2:
                statusName = "等待";
                break;
            case 3:
                statusName = "故障";
                break;
            case 4:
                statusName = "离线";
                break;
        }
        this.status = status;
    }


    private static final long serialVersionUID = 1L;
}
